package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.ModefyPwsdContract;
import com.magic.gre.mvp.model.ModefyPwsdModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-01-10 17:01
 * 文件名: ModefyPwsdpresenterImpl
 * 描述:
 */
public class ModefyPwsdpresenterImpl extends BasePresenterImpl<ModefyPwsdContract.View, ModefyPwsdContract.Model>
        implements ModefyPwsdContract.Presenter {
    public ModefyPwsdpresenterImpl(ModefyPwsdContract.View view) {
        super(view);
    }

    @Override
    protected ModefyPwsdContract.Model creatModel() {
        return new ModefyPwsdModelImpl();
    }

    @Override
    public void pModify(String phone,String newPwd) {
        mModel.mModify(new CommonObserver<BaseObjectModel>(new TypeToken<BaseObjectModel>(){}.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel baseObjectModel) {
                mView.vModify();
            }

            @Override
            public void onError(int status, String msg) {
                mView.doPrompt(msg);
            }
        }, phone,newPwd);
    }
}
